package Kuaishou;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Test03线程池测试 {
    public static final ExecutorService MY_POOL = new ThreadPoolExecutor(50,
            100,
            0,
            TimeUnit.MILLISECONDS,
            new LinkedBlockingDeque<>(100),
//            (r, executor) ->
//                    System.out.println(("执行错误！核心线程数:" + executor.getPoolSize() + ", 阻塞队列:" + executor.getQueue().size())));
//            new ThreadPoolExecutor.AbortPolicy());
            new ThreadPoolExecutor.CallerRunsPolicy());


    public static void main(String[] args) {
        MY_POOL.submit(() -> {
            System.out.print(0);
        });

        MY_POOL.shutdown();
        System.out.print(1);

        MY_POOL.execute(() -> {
            System.out.print(2);
        });
    }
}

